
Yacon.widget.Calendar = function(conText)
{
	
	this.today       = new Date();
	
	this.days        = new Array(constSunday, constMonday, constTuesday, constWednesday, constThursday, constFriday, constSaturday);
	
	/*日历类型*/
	this.type        = "date";
	
    /*激活索引*/
	this.activeCellIndex = 0;
	
	/*日历标示值*/
	this.calendarSign    = "";
	/*日历本月起始日*/
	this.startday        = 0;

	/*本年*/
	this.year        = "";
	/*上一年*/
	this.preYear     = "";
	/*下一年*/
	this.nextYear    = "";	
    /*本月字符空与数字零相等*/
    this.month       = "12";
    /*上个月*/
    this.preMonth    = "";
    /*下个月*/
    this.nextMonth   = "";
    
    /*本日*/
	this.day         = this.today.getDate();
	/*现小时	*/
	this.hour        = this.today.getHours();
	/*现分钟*/
	this.minute      = this.today.getMinutes();
	/*现秒*/
	this.second      = this.today.getSeconds();

	Yacon.apply(this,conText);
	
	this.create(); 	
}

Yacon.widget.Calendar.Extend(Yacon.widget.WinControl,{
		
	getSignHTML:function(type)
	{
		if (type)
			this.type = type;
		
		if (this.type != "month")
		{
			this.calendarSign = "<TABLE border=0 id='CalendarTable' class='calendar' rule=all>";
		}else
		{
		   this.calendarSign = "<TABLE border=0 id='CalendarTable' class='calendarMonth' rule=all>";
		}
		this.createTitle();
		this.createBody();
		this.createEnd();
		
		this.calendarSign += "</TABLE>";
		this.year = "";
		
		return this.calendarSign;
		
	},	
	createTitle:function()
	{
		if (this.type != "month")
		{
			this.calendarSign+="<TR class=title><TD><TABLE><TR><TD class='buttonLastYear' >";			
			this.calendarSign+="<IMG  id='buttonLastMonth' src="+Yacon.path.getImgPath("widget/page-prev.gif")+" title='"+constLastMonth+"'  onclick='Yacon.widget.Calendar.events.preCalendarMonth()'>";
			this.calendarSign+="</TD><TD class='textYear'><INPUT id='_calender_year' type=text  size=4 maxlength=4 >年</TD><TD class='_calender_month'>";
			this.calendarSign+="<INPUT id='_calender_month' type=text  size=2 maxlength=2 >月</TD><TD class='buttonDate'>";									
			//this.calendarSign+="<IMG  type='year' src="+Yacon.path.getImgPath("arrow.gif")+" title='"+constYearMonth+"'  onclick='Yacon.widget.Calendar.events.choseYearMonth(this)'>";
			this.calendarSign+="</TD><TD class='buttonNextMonth'><IMG  id='buttonLastYear' src="+Yacon.path.getImgPath("widget/page-next.gif")+" title='"+constNextMonth+"'  onclick='Yacon.widget.Calendar.events.nextCalendarMonth()'>";
			this.calendarSign+="</TD></TR></TABLE></TD></TR>";
		}else
		{
			this.calendarSign+="<TR class=title><TD><TABLE><TR><TD class='buttonLastYear'>";			
			this.calendarSign+="<IMG  id='buttonLastMonth' src="+Yacon.path.getImgPath("widget/page-prev.gif")+"  title='"+constLastYear+"'  onclick='Yacon.widget.Calendar.events.preCalendarYear()'>";
			this.calendarSign+="</TD><TD class='textYear'><INPUT id='_calender_year' type=text size=12 class=editor  maxlength=4 ></TD><TD class='buttonNextYear'>";
			this.calendarSign+="<IMG  id='buttonLastYear' src="+Yacon.path.getImgPath("widget/page-next.gif")+"  title='"+constNextYear+"' onclick='Yacon.widget.Calendar.events.nextCalendarYear()'>";			
			this.calendarSign+="</TD></TR></TABLE></TD></TR>";
		}
	},
	createBody:function()
	{
		if (this.type != "month")
		{
			this.calendarSign+="<TR class=data><TD><TABLE  class='calendarCell'><TR class='calendarWeek'>";
			for (var i=0;i<=6;i++){	this.calendarSign+="<TD>"+this.days[i]+"</TD>";}
			this.calendarSign+="</TR></TABLE></TD></TR><TR class=data><TD><TABLE id='calendarData' class='calendarCell'  cellSpacing ='1' " +
					"onclick='Yacon.widget.Calendar.events.calendarCellClick()' ondblclick='Yacon.widget.Calendar.events.calendarCellDBClick()'> ";
			for(var i=0;i<=5;i++){this.calendarSign+="<TR class='calendarDay'>";for(var j=0;j<=6;j++){this.calendarSign+="<TD></TD>";}this.calendarSign+="</TR>";}
			this.calendarSign+="</TABLE></TD></TR>";
		}else{
			this.calendarSign+="<TR class=data><TD><TABLE id='calendarData' class='monthCell' onclick='Yacon.widget.Calendar.events.calendarCellOnclick()'ondblclick='Yacon.widget.Calendar.events.calendarCellDBClick()'>";
			this.calendarSign+="<tr class='calendarMonth'><td>一月</td><td>二月</td><td>三月</td><td>四月</td></tr>";
			this.calendarSign+="<tr class='calendarMonth'><td>五月</td><td>六月</td><td>七月</td><td>八月</td></tr>";
			this.calendarSign+="<tr class='calendarMonth'><td>九月</td><td>十月</td><td>十一月</td><td>十二月</td></tr>";
			this.calendarSign+="</TABLE></TD></TR>";
		}
	},
	createEnd:function()
	{	
		if (this.type != "month")
		{
		 	this.calendarSign+="<TR class=footer><TD><TABLE border=0 ><TR>";	    
			if (this.type == "datetime"){
				this.calendarSign+= "<TD><INPUT id='_calender_hour' type=text  size=2 maxlength=2>:<INPUT id='_calender_minute' type=text  size=2 maxlength=2>";
				this.calendarSign+="<IMG  type='time' src="+Yacon.path.getImgPath("widget/arrow.gif")+" title='"+constYearMonth+"'  onclick='Yacon.widget.Calendar.events.choseYearMonth(this)'></TD>";
			}
			this.calendarSign+="<TD align='right'><INPUT class='button' type=button id='buttonToday' value='"+constToday+" "+this.today.getFullYear()+"-"+(this.today.getMonth()+1)+"-"+this.today.getDate()+"' onclick='Yacon.widget.Calendar.events.calendarToday()'</TD></TR></TABLE></TD></TR>";
		}else{
			this.calendarSign+="<TR class=footer><TD>";
			this.calendarSign+="<INPUT class='button' type=button id='buttonToday' value='"+"本年月"+" "+this.today.getFullYear()+"-"+(this.today.getMonth()+1)+"' onclick='Yacon.widget.Calendar.events.calendarToday()' </TD></TR> ";
		}
	},
	changeCalendarDate:function(year,month,day)
	{	
		if (this.year==year && this.month==month && this.day==day) return;
		
		this.year  = year;
		this.month = month;
		if (Yacon.getInt(this.minute)<10)
			this.minute = "0" + Yacon.getInt(this.minute);
		
		if (day)
			this.day = day;
		
		if (this.month==0){
			this.preMonth=11;
			this.preYear=this.year-1;
		}else{
			this.preMonth=this.month-1;
			this.preYear=this.year;
		}
		if (this.month==11){
			this.nextMonth=0;
			this.nextYear=this.year+1;
		}else{
			this.nextMonth=this.month+1;
			this.nextYear=this.year;
		}
		
		document.getElementById("_calender_year").value   = this.year;
		document.getElementById("_calender_year").onpropertychange   = Yacon.widget.Calendar.events.calendarYearChange;
		
		if (this.type == "datetime")
		{
			document.getElementById("_calender_hour").value    = this.hour;
			document.getElementById("_calender_minute").value  = this.minute;
		}
		if (this.type != "month")
		{
			document.getElementById("_calender_month").value  = this.month+1;
			document.getElementById("_calender_month").onpropertychange  = Yacon.widget.Calendar.events.calendarMonthChange;
		}		
		this.startday=(new Date(year,month,1)).getDay();	
		if (this.startday==0) this.startday=7;
				
		var curNumdays   = Yacon.getNumberOfDays(this.year,this.month);
		var preNumdays   = Yacon.getNumberOfDays(this.preYear,this.preMonth);
		var nextNumdays  = Yacon.getNumberOfDays(this.nextYear,this.nextMonth);
		var startDate    = preNumdays - this.startday + 1;
		var endDate      = 42 - curNumdays - this.startday;
		
		var datenum=0;
		var rowInx = 0;
		var cellInx =0;
		var cell;
		
		for (var i=startDate;i<=preNumdays;i++)
		{
			rowInx  = parseInt(datenum/7);
			cellInx = datenum%7;
			
			cell =  document.getElementById("calendarData").rows[rowInx].cells[cellInx];
			cell.monthAttribute="pre";
			cell.className = "pre";
			cell.innerText=i;
			
			if (datenum%7==0 ||datenum%7==6 )
				cell.style.color= "salmon";
			datenum++;
		}
		for (var i=1;i<=curNumdays;i++)
		{
			rowInx  = parseInt(datenum/7);
			cellInx = datenum%7;
			cell =  document.getElementById("calendarData").rows[rowInx].cells[cellInx];
			
			cell.monthAttribute="cur";
			if (datenum != this.activeCellIndex){
				cell.className = "cur";
			}			
			cell.innerText=i;
			if (datenum%7==0 ||datenum%7==6 )
				cell.style.color= "salmon";
			datenum++;
		}
		for (var i=1;i<=endDate;i++)
		{
			rowInx  = parseInt(datenum/7);
			cellInx = datenum%7;
			
			cell =  document.getElementById("calendarData").rows[rowInx].cells[cellInx];
			
			cell.monthAttribute="next";
			cell.className = "next";
			cell.innerText=i;
			
			if (datenum%7==0 ||datenum%7==6 )
				cell.style.color= "salmon";
			
			datenum++;
		}		
		this.setActiveCell(this.startday + this.day - 1);
	},
	
	setActiveCell:function(cellIndex)
	{
		var rowInx  = parseInt(cellIndex/7);
		var cellInx = cellIndex%7;
		var actCell =  document.getElementById("calendarData").rows[rowInx].cells[cellInx];
		if (!actCell)
			return;		
		
		var rowInx  = parseInt(this.activeCellIndex/7);
		var cellInx = this.activeCellIndex%7;
		
		var cell =  document.getElementById("calendarData").rows[rowInx].cells[cellInx];	
		if (cell.monthAttribute == "cur"){
			cell.className = "cur";
		}
		else{
			cell.className = "pre";
		}		
		
		actCell.className = "selected";
		this.activeCellIndex = cellIndex;
	},
	setCalendarActiveCell:function(cell)
	{
		if (cell.tagName.toLowerCase()!="td") return;
		
		var _activeCellIndex=cell.parentElement.rowIndex*7+cell.cellIndex;
		
		if (this.activeCellIndex==_activeCellIndex) return;

		var monthAttribute = cell.monthAttribute;
		
		switch (monthAttribute){
			case "pre":{
				this.setCalendarDate(new Date(this.preYear,this.preMonth,Yacon.getNumberOfDays(this.preYear,this.preMonth)-this.startday+_activeCellIndex+1));
				break;
			}
			case "cur":{
				
				this.setCalendarDate(new Date(this.year,this.month,_activeCellIndex-this.startday+1));
				break;
			}
			case "next":{
				this.setCalendarDate(new Date(this.nextYear,this.nextMonth,_activeCellIndex - Yacon.getNumberOfDays(this.year,this.month)-this.startday+1));
				break;
			}
		}		
	},
	changeYearMonth:function(year, month) 
	{
		if (this.year == year && this.month == month) return;
		
		this.year  = Yacon.getInt(year);
		this.month = Yacon.getInt(month);	
	
		document.getElementById("_calender_year").value            = this.year;
		document.getElementById("_calender_year").onpropertychange = Yacon.widget.Calendar.events.calendarYearChange;
		
		var datenum=0;
		for (var i = 0;i <= 11;i++){
			var cell = calendarData.cells[i];			
			cell.className = "cur";	
		}			
		this.setActiveMonthCell(calendarData.cells[this.month]);
	},
	setActiveMonthCell:function(cell)
	{
		if (cell.tagName.toLowerCase() != "td") return;
		
		var precell       = calendarData.cells[this.activeCellIndex];	
		precell.className = "cur";
		
		var _activeCellIndex = cell.parentElement.rowIndex*4 + cell.cellIndex;
		cell.className       = "selected";
		
		this.year  = document.getElementById("_calender_year").value;
		this.month = _activeCellIndex;
			
		this.activeCellIndex = _activeCellIndex;
	},
	setCalendarTime :function(hour,minute)
	{
		this.hour    = hour;
		this.minute  = minute;
		
		_calender_hour.value   = this.hour;
		_calender_minute.value  = this.minute;
		
		this.getAttachControl().setFieldValue();
	},
	setCalendarDate:function(date)
	{	
		if (this.type != "month")
		{
			this.changeCalendarDate(date.getFullYear(),date.getMonth(),date.getDate());
			this.getAttachControl().setFieldValue();
		}else
		{
			
			this.changeYearMonth(date.getFullYear(),date.getMonth());
			this.getAttachControl().setFieldValue();
		}
	},		
	show:function(fieldValue)
	{
		var showDate = null;
		if(Yacon.isEmpty(fieldValue))
			showDate = new Date();
		else
		{
			var dateArr = fieldValue.split("-");		
			if (dateArr.length ==3)
			{
				
				var thisYear   = Yacon.getInt(dateArr[0]);
				var thisMonth  = Yacon.getInt(dateArr[1])-1;
				var thisDay    = Yacon.getInt(dateArr[2]);
				
				if(thisYear <4000 && thisYear >1800 && thisMonth >0 && thisMonth <13 && thisDay >0 && thisDay <32 )
					showDate = new Date(thisYear,thisMonth,thisDay);
				else
					showDate = new Date();
			}else
				showDate = new Date();	
		}
		
		this.setCalendarDate(showDate);	
	}
});

Yacon.widget.Calendar.events = {
		
	preCalendarYear:function()
	{
		window.Calendar.setCalendarDate(new Date(Yacon.getInt(window.Calendar.year)-1,window.Calendar.month,window.Calendar.day));
	},
	nextCalendarYear:function()
	{
		window.Calendar.setCalendarDate(new Date(Yacon.getInt(window.Calendar.year)+1,window.Calendar.month,window.Calendar.day));
	},
	preCalendarMonth:function()
	{
		window.Calendar.setCalendarDate(new Date(window.Calendar.preYear,window.Calendar.preMonth,window.Calendar.day));
	},
	nextCalendarMonth:function()
	{
		window.Calendar.setCalendarDate(new Date(window.Calendar.nextYear,window.Calendar.nextMonth,window.Calendar.day));
	},
	calendarYearChange:function()
	{
		if (event.propertyName=="value")
		{
			if (event.srcElement.value.length ==4)
			{			
				window.Calendar.setCalendarDate(new Date(event.srcElement.value,window.Calendar.month,window.Calendar.day));
			}
		}
	},
	calendarMonthChange:function()
	{
		if (event.propertyName=="value")
		{
			if (Yacon.getInt(event.srcElement.value)>0 && Yacon.getInt(event.srcElement.value)<=12)
			{
				window.Calendar.setCalendarDate(new Date(window.Calendar.year,Yacon.getInt(event.srcElement.value)-1,window.Calendar.day));
			}
		}
	},
	calendarToday:function()
	{
		window.Calendar.setCalendarDate(window.Calendar.today);
		window.Calendar.getAttachControl().hidden();
	},
	calendarCellClick:function()
	{
		
		if (window.Calendar.calendarType != "month")
		{
			window.Calendar.setCalendarActiveCell(event.srcElement);
		}else
		{ 
			window.Calendar.setActiveMonthCell(event.srcElement);
		}
	},
	calendarCellDBClick:function()
	{
		
		window.Calendar.getAttachControl().hidden();
	},	
	choseYearMonth:function(el)
	{
		if (!window.Calendar.calendarChange)
			window.Calendar.calendarChange = new Yacon.widget.CalendarChange();
		
		window.Calendar.calendarChange.setAttachControl(window.Calendar);
		window.Calendar.calendarChange.setConText({type:el.type});
		
		window.Calendar.calendarChange.show();
	}	
};

Yacon.widget.CalendarChange = function(conText)
{
	this.type    = "time";
	var nowday  = new Date();
	var nowyear = nowday.getFullYear();
	this.months  = new Array(constJan,constFeb,constMar,constApr,constMay,constJun,constJul,constAug,constSep,constOct,constNov,constDec);
	
	Yacon.apply(this,conText);
	this.create();
}

Yacon.widget.CalendarChange.Extend(Yacon.widget.WinControl,{
	 
	 create:function()
	 {
		this.calendarSign="<TABLE id='cal_change_year' class='cal_change_year' border=0 rull=all >";
		this.calendarSign+="<tr><td colSpan=6><table id='change_year' class='change_year' border=0 rull=all>";
		for(var i=0;i<4;i++)
		{
			this.calendarSign+="<tr>";
			if (i==0)
				this.calendarSign+="<td rowspan=4 class='title'></td>";
				
			for(var j=0;j<6 ;j++)
			{
					this.calendarSign+="<td onclick='Yacon.widget.CalendarChange.events.yearClick(this)' ondblclick='Yacon.widget.CalendarChange.events.yearDBClick(this)'></td>";
			}
				
			this.calendarSign+="</tr>";
		}
		this.calendarSign+="</table></td></tr>";
		this.calendarSign+="<tr><td colSpan=6><table id='change_month' class='change_month' border=0 rull=all>";
		for(var i=0;i<2;i++)
		{
			this.calendarSign+="<tr>";
			if (i==0)
				this.calendarSign+="<td rowspan=2 class='title'></td>";
			for(var j=0;j<6;j++)
			{
				this.calendarSign+="<td class='cur' onclick='Yacon.widget.CalendarChange.events.monthClick(this)' ondblclick='Yacon.widget.CalendarChange.events.monthDBClick(this)'></td>";
			}				
			this.calendarSign+="</tr>";				
		}
		this.calendarSign+="</table></td></tr><tr class='change_buttom' >";
		this.calendarSign+="<td><IMG id='changePrev'src="+Yacon.path.getImgPath("page-prev.gif")+"  title='"+constLastYear+"'  onclick='Yacon.widget.CalendarChange.events.preChangeYear()'></td>";
		this.calendarSign+="<td ><IMG id='changeNext' src="+Yacon.path.getImgPath("page-next.gif")+" title='"+constLastYear+"' onclick='Yacon.widget.CalendarChange.events.nextChangeYear()'></td>";
		this.calendarSign+="<td style='text-align: right' colSpan=2><span   onclick='Yacon.widget.CalendarChange.events.buttonOK()'>确定</span></td>";
		this.calendarSign+="<td style='text-align: center' colSpan=2><span  onclick='Yacon.widget.CalendarChange.events.buttonClose()'>取消</span></td></tr>";
		this.calendarSign+="</TABLE>";	
				
		//this.initialization();
	},
	setConText:function(conText)
	{
		
		Yacon.apply(this,conText);
		this.initialization();
	},
	initialization:function()
	 {
		if (!this.listContainer)
			this.listContainer = new Yacon.widget.ListContainer();		
		
		
     	var pos = Yacon.getAbsPosition(document.all["CalendarTable"]);     	
     	if (!this.type=="time")
     	{
     		pos[2]=280;
     		pos[3]=200;
     	}
     	this.listContainer.setConText(
 	    {
 	    	top:pos[1],
 	    	left:pos[0],
 	    	width:pos[2],
 	    	height:pos[3],
 	    	zindex:10000 	    	
 	    });
     	
     	this.listContainer.appenChild(this.calendarSign);
     	
	 	if (this.type=="time")
	 	{
	 		document.all["changePrev"].style.display='none';
	 		document.all["changeNext"].style.display='none';
	 	}else
	 	{
	 		document.all["changePrev"].style.display='block';
	 		document.all["changeNext"].style.display='block';
	 	}
	 		
	     this.element = document.all["cal_change_year"];
	     this.addEvents("mouseleave",Yacon.widget.CalendarChange.events.buttonClose);
	     this.element.Control = this;
	     this.year    = window.Calendar.year;
	     this.month   = window.Calendar.month;
	     this.hour    = window.Calendar.hour;
	     this.minute  = window.Calendar.minute;
	     this.changeYear(this.year,this.month);
	     
	 },
	 changeYear:function(year,month)
	 {
	 	if (this.type!="time")
	 	{
	 		this.prstartYear = Yacon.getInt(year) - 12;
	 		this.nestartYear = Yacon.getInt(year) + 12;	
	 		var yearnum=1;
	 		change_year.cells[0].innerText= "年";	
	 		for (var i= this.prstartYear;i<this.nestartYear;i++){
	 			cell = change_year.cells[yearnum];
	 			if (cell)
	 			{
	 				cell.className = "cur";		
	 				cell.innerText = i;			
	 			}
	 			yearnum ++;
	 		}
	 		change_month.cells[0].innerText= "月";
	 		for (var i= 0;i<12;i++){
	 			cell = change_month.cells[i+1];
	 			if (cell)
	 			{
	 				cell.className = "cur";		
	 				cell.innerText= this.months[i];			
	 			}
	 		}	 		
	 	}else
	 	{
	 		change_year.cells[0].innerText= "时";	
	 		for (var i= 0;i<24;i++){
	 			cell = change_year.cells[i+1];
	 			if (cell)
	 			{
	 				cell.className = "cur";		
	 				cell.innerText= i;			
	 			}
	 		}
	 		change_month.cells[0].innerText= "分";
	 		for (var i= 0;i<12;i++){
	 			cell = change_month.cells[i+1];
	 			if (cell)
	 			{
	 				cell.className = "cur";		
	 				cell.innerText= i*5;			
	 			}
	 		}		
	 	}
	 	this.activeYearMonth();
	 },
	 activeYearMonth:function()
	 {
		if (this.type!="time")
	 	{
	 		for (var i= 0;i<change_year.cells.length;i++){
	 			cell = change_year.cells[i];
	 			if (Yacon.getInt(cell.innerText)==Yacon.getInt(this.year))
	 			{
	 				if (this.activeCellYear)
	 					this.activeCellYear.className = "cur";
	 				this.activeCellYear = cell;
	 				this.activeCellYear.className = "selected";
	 			}		
	 		}
	 		
	 		if (change_month.cells[Yacon.getInt(this.month)+1])
	 		{
	 			if (this.activeCellMonth)
	 				this.activeCellMonth.className = "cur";
	 			this.activeCellMonth = change_month.cells[Yacon.getInt(this.month)+1];
	 			this.activeCellMonth.className = "selected";			
	 		}
	 	}else
	 	{
	 		if (Yacon.getInt(this.minute)%5 >0)
	 			minute = (Math.floor(Yacon.getInt(this.minute)/5)+1)*5;
	 		else
	 			minute = Yacon.getInt(this.minute);
	 		
	 		if (minute ==60)
	 		{
	 			minute =0;
	 			this.hour = Yacon.getInt(this.hour)+1
	 		}		
	 		
	 		this.minute = minute; 
	 		if (change_year.cells[Yacon.getInt(this.hour)+1])
	 		{
	 			if (this.activeCellYear)
	 				this.activeCellYear.className = "cur";
	 			this.activeCellYear = change_year.cells[Yacon.getInt(this.hour)+1];
	 			this.activeCellYear.className = "selected";			
	 		}
	 		if (change_month.cells[(minute/5)+1])
	 		{
	 			if (this.activeCellMonth)
	 				this.activeCellMonth.className = "cur";
	 			this.activeCellMonth = change_month.cells[(minute/5)+1];
	 			this.activeCellMonth.className = "selected";			
	 		}		
	 	}
	 },
	 show:function()
	 {
		 window.activeElement =this;
		 this.listContainer.falshShow();
	 }
	 
});

Yacon.widget.CalendarChange.events = {
		
	yearClick:function(el)
	{
		var cal_con = document.all["cal_change_year"].Control;
		if (!cal_con.type.isEqual("time"))
			cal_con.year  = el.innerText;
		else
			cal_con.hour  = el.innerText;
		
		cal_con.activeYearMonth();
	},
	yearDBClick:function(el)
	{
		this.yearClick(el);
		this.buttonOK();
	},
	monthClick:function(el)
	{
		var cal_con = document.all["cal_change_year"].Control;
		if (!cal_con.type.isEqual("time"))
		{
			if (el.parentNode.rowIndex ==0)
				cal_con.month  = el.cellIndex-1;
			else
				cal_con.month  = (el.parentNode.rowIndex*6)+el.cellIndex;
		}else
		{
			cal_con.minute  = el.innerText;
		}
		cal_con.activeYearMonth();
	},
	monthDBClick:function(el)
	{
		this.monthClick(el);
		this.buttonOK();
	},
	preChangeYear:function(el)
	{
		document.all["cal_change_year"].Control.changeYear(document.all["cal_change_year"].Control.prstartYear-12);
	},
	nextChangeYear:function(el)
	{
		document.all["cal_change_year"].Control.changeYear(document.all["cal_change_year"].Control.nestartYear+12);
	},
	buttonOK:function()
	{
		var ch = document.all["cal_change_year"].Control;
		if (ch.type!="time")
			ch.getAttachControl().setCalendarDate(new Date(ch.year ,ch.month,ch.getAttachControl().day));
		else
			ch.getAttachControl().setCalendarTime(ch.hour,ch.minute);
		
		ch.listContainer.falshHide();
	},
	buttonClose:function()
	{
		document.all["cal_change_year"].Control.listContainer.falshHide();
	}
}
		

var constMonday    = "一";
var constTuesday   = "二";
var constWednesday = "三";
var constThursday  = "四";
var constFriday    = "五";
var constSaturday  = "六";
var constSunday    = "日";
var constYearMonth = "选择年月";
var constLastMonth = "上个月";
var constNextMonth = "下个月";
var constLastYear  = "前24年";
var constNextYear  = "后24年";
var constToday     = "今天";
var constTime      = "时间：";
var constJan       = "一月";
var constFeb       = "二月";
var constMar       = "三月";
var constApr       = "四月";
var constMay       = "五月";
var constJun       = "六月";
var constJul       = "七月";
var constAug       = "八月";
var constSep       = "九月";
var constOct       = "十 月";
var constNov       = "十一月";
var constDec       = "十二月";


if (!window.Calendar && document.body) 
	window.Calendar = new Yacon.widget.Calendar();




